namespace WP7Contrib.Services.BingMaps.Model
{
    using System;
    using Common;

    public class Avoid : BaseModel, IEquatable<Avoid>, ICloneable<Avoid>
    {
        private bool highways;
        private bool tolls;
        private bool minimizeHighways;
        private bool minimizeTolls;

        public bool Highways
        {
            get
            {
                return this.highways;
            }
            set
            {
                this.SetPropertyAndNotify(ref this.highways, value, () => this.Highways);
            }
        } 

        public bool Tolls
        {
            get
            {
                return this.tolls;
            }
            set
            {
                this.SetPropertyAndNotify(ref this.tolls, value, () => this.Tolls);
            }
        } 

        public bool MinimizeHighways
        {
            get
            {
                return this.minimizeHighways;
            }
            set
            {
                this.SetPropertyAndNotify(ref this.minimizeHighways, value, () => this.MinimizeHighways);
            }
        } 

        public bool MinimizeTolls
        {
            get
            {
                return this.minimizeTolls;
            }
            set
            {
                this.SetPropertyAndNotify(ref this.minimizeTolls, value, () => this.MinimizeTolls);
            }
        }

        public static bool operator ==(Avoid a1, Avoid a2)
        {
            return Equals(a1, a2);
        }

        public static bool operator !=(Avoid a1, Avoid a2)
        {
            return !Equals(a1, a2);
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj))
            {
                return false;
            }

            return obj is Avoid && this.Equals((Avoid)obj);
        }

        public override int GetHashCode()
        {
            return this.CombineHashCodes(this.Highways,
                                         this.Tolls,
                                         this.MinimizeHighways,
                                         this.MinimizeTolls);
        }

        public bool Equals(Avoid avoid)
        {
            if (ReferenceEquals(null, avoid))
            {
                return false;
            }

            if (this.Highways != avoid.Highways)
            {
                return false;
            }

            if (this.Tolls != avoid.Tolls)
            {
                return false;
            }

            if (this.MinimizeHighways != avoid.MinimizeHighways)
            {
                return false;
            }

            if (this.MinimizeTolls != avoid.MinimizeTolls)
            {
                return false;
            }

            return true;
        }

        public Avoid ShallowClone()
        {
            return this.DeepClone();
        }

        public Avoid DeepClone()
        {
            var avoid = new Avoid
            {
                Highways = this.Highways,
                Tolls = this.Tolls,
                MinimizeHighways = this.MinimizeHighways,
                MinimizeTolls = this.MinimizeTolls
            };

            return avoid;
        }
    }
}